{{include file="../include/01_head.tpl"}}
{{include file="../include/02_menu.tpl"}}
<script type="text/javascript">var base_url = "{{""|base_url}}", edialog, ndialog;</script>
<div class="g-d-w lh28 p-l-12 b-d-b-c-ccc f-w-b f-z-11">Privileges</div>
<div class="b-g-c-eee b-d-b-c-ccc p-4">
    <div class="p-r">
        <div class="grid_10 p-a t-0 l-0 b-0 b-g-c-w z-i-1 b-d-c-ccc">
            <div class="h-24 b-d-b-c-ccc l-h-24 g-d-w">
                <span class="p-l-8 f-w-b">List Privileges</span>
                <span class="p-r-8 p-l-20 f-r add c-s-p a" onclick="privilege_detail('')">Add</span>
            </div>
            <div class="p-a t-24 l-0 r-0 b-0 o-v-f-a">
                <table class="classic-table wi">
                    <tr class="g-d-w l-h-16">
                        <td class="w-20"></td>
                        <td>Name</td>
                        <td class="w-40">Position</td>
                        <td class="w-40">#</td>
                    </tr>
                    {{foreach $privileges as $pri}}
                        <tr class="l-h-16">
                            <td class="w-20"><input type="checkbox" {{if $pri->apri_status==='true'}}checked="1"{{/if}}/></td>
                            <td>{{$pri->apri_name}}</td>
                            <td class="w-40">{{$pri->apri_position}}</td>
                            <td class="w-40">
                                <img class="s-w-h c-s-p" 
                                     onclick="privilege_detail('{{$pri->apri_id}}')"
                                     src='{{base_url()}}libraries/images/16/icon_edit.png' alt=""/>
                            </td>
                        </tr>
                    {{/foreach}}
                </table>
            </div>
        </div>
        <div class="b-g-c-eee p-r r-0 prefix_10">
            <div id="editor_box" class="m-l-8 b-d-c-ccc p-r" style="min-height: 500px">
                <div class="p-a t-0 l-0 b-0 r-0 tranf-w-50 d-p-n" style="z-index: 1001"></div>
                <div class="p-a t-0 l-0 b-0 r-0 b-g-ldg b-g-c-w i-l-d d-p-n" style="z-index: 1002"></div>
                <div class="content-biz"></div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script type="text/javascript">
    function privilege_detail(id){
        $("#editor_box .i-l-d").stop()
            .removeClass("b-g-c-w-50")
            .show();
        $("#editor_box .content-biz").load(
            "{{base_url()}}admincp/privilege/editor/" + id,
            function() {
                $("#editor_box .i-l-d").fadeOut(1000);
                $("#apri_frm").validationEngine();
            }
        );
    }
    function update_pri(){
        if( $('#apri_frm').validationEngine('validate') === false)return false;
        new backend({
            url         :   "{{"admincp/privilege/save"|base_url}}",
            data        :   {
                apri_id      :   $("#pri_id").val(),
                apri_name       :   $("#pri_name").val(),
                apri_key       :   $("#pri_key").val(),
                apri_position  :   $("#pri_position").val(),
                apri_status    :   $("#pri_status").val(),
                apri_description      :   $("#pri_desc").val()
            },
            datatype    :   "json",
            proc_start  :   proc_sart("#editor_box"),
            proc_end    :   proc_end("#editor_box"),
            callback    :   function(data){
                if(data.result<0){
					new bckdialog({type:'error'}).open(data.message);
                }else{
                    uiMessage(data.message);
                }
            }
        }).call();
        return false;
    }
</script>
{{include file="../include/04_foot.tpl"}}
